package com.yfqy.app.modules.customer.resource;

import com.yfqy.app.domain.vo.ResultVO;
import com.yfqy.app.modules.customer.dto.ApplyForLeaderDTO;
import com.yfqy.app.modules.customer.dto.AvatarNicknameDTO;
import com.yfqy.app.modules.customer.service.CustomerService;
import com.yfqy.app.modules.customer.vo.CustomerDetailVO;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/client/customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;


    /**
     * 普通用户申请成为分销商
     *
     * @param dto
     * @return
     */
    @PostMapping("/apply-leader")
    public ResultVO<String> applyForLeader(@Valid @RequestBody ApplyForLeaderDTO dto) {
        return ResultVO.data(customerService.applyForLeader(dto));
    }

    /**
     * 用户个人信息
     *
     * @return
     */
    @GetMapping("/userInfo")
    public ResultVO<CustomerDetailVO> userInfo() {
        return ResultVO.data(customerService.userInfo());
    }

    /**
     * 更新昵称和头像
     *
     * @return
     */
    @PostMapping("/updateAvatarNickname")
    public ResultVO<String> updateAvatarNickname(@RequestBody AvatarNicknameDTO avatarNicknameDTO) {
        return ResultVO.data(customerService.updateAvatarNickname(avatarNicknameDTO));
    }

    /**
     * 绑定手机号
     *
     * @return
     */
    @PostMapping("/bindPhoneNumber/{phoneNumber}")
    public ResultVO<String> bindPhoneNumber(@PathVariable String phoneNumber) {
        return ResultVO.data(customerService.bindPhoneNumber(phoneNumber));
    }

}
